﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Runtime.InteropServices.JavaScript;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.Data;
using Volo.Abp.Domain.Entities.Auditing;
using Volo.Abp.MultiTenancy;

namespace Himp.Platform
{
    /// <summary>
    /// 消息发送记录
    /// </summary>
    public class EventMsgSendRec : AuditedAggregateRoot<Guid>, IMultiTenant, IHasExtraProperties
    {
        /// <summary>
        /// 消息类型
        /// </summary>
        public Guid MsgBizTypeId { get; private set; }

        ///// <summary>
        ///// 消息类型
        ///// </summary>
        //public MsgBizType MsgBizType { get; set; }

        /// <summary>
        /// 消息名称
        /// </summary>
        public string MsgName { get; private set; }

        /// <summary>
        /// 消息内容
        /// </summary>
        public string MsgCont { get; private set; }

        /// <summary>
        /// 消息发送人ID
        /// </summary>
        public Guid? MsgSendUserid { get; set; }

        /// <summary>
        /// 消息发送人名称
        /// </summary>
        public string? MsgSendUsername { get; set; }

        /// <summary>
        /// 消息发送部门Id
        /// </summary>
        public Guid? MsgSendDeptid { get; set; }

        /// <summary>
        /// 消息发送部门名称
        /// </summary>
        public string? MsgSendDeptname { get; set; }

        /// <summary>
        /// 消息接收部门ID
        /// </summary>
        public string? MsgRecvDeptid { get; set; }

        /// <summary>
        /// 消息接收部门名称
        /// </summary>
        public string? MsgRecvDeptname { get; set; }

        /// <summary>
        /// 消息接收人员Id
        /// </summary>
        public Guid? MsgRecvUserid { get; set; }

        /// <summary>
        /// 消息接收人员名称
        /// </summary>
        public string? MsgRecvUsername { get; set; }

        /// <summary>
        /// 消息状态
        /// </summary>
        public EnumMsgStats MsgStats { get; set; }

        /// <summary>
        /// 消息等级
        /// 默认
        /// 锁屏
        /// 报警
        /// </summary>
        public EnumMsgLv MsgLv { get; private set; }

        ///// <summary>
        ///// 业务编号
        ///// </summary>
        //public string? BizNo { get; set; }


        //public List<MsgReadRec>? MsgReadRecs { get; set; }

        /// <summary>
        /// 
        /// </summary>
        public Guid? TenantId { get; set; }


        public EventMsgSendRec()
        { 
            
        }

        public EventMsgSendRec(Guid msgBizTypeId, string msgName, string msgCont, EnumMsgLv msgLv)
        {
            MsgBizTypeId = msgBizTypeId;
            MsgName = msgName;
            MsgCont = msgCont;
            MsgLv = msgLv;
            MsgStats = EnumMsgStats.创建;
        }
    }


    public static class MsgSendRecExtensions
    {
        private const string ReasonPropertyName = "Reason";

        public static void SetReason(this EventMsgSendRec item, string pars)
        {
            item.SetProperty(ReasonPropertyName, pars);
        }

        public static string GetReason(this EventMsgSendRec item)
        {
            return item.Property<string>(ReasonPropertyName);
        }

        private const string HandlePropertyName = "Handle";

        public static void SetHandle(this EventMsgSendRec item, string pars)
        {
            item.SetProperty(HandlePropertyName, pars);
        }

        public static string GetHandle(this EventMsgSendRec item)
        {
            return item.Property<string>(HandlePropertyName);
        }

        private const string NotePropertyName = "Note";

        public static void SetNote(this EventMsgSendRec item, string pars)
        {
            item.SetProperty(NotePropertyName, pars);
        }

        public static string GetNote(this EventMsgSendRec item)
        {
            return item.Property<string>(NotePropertyName);
        }

        private const string AnnexPropertyName = "Annex";

        public static void SetAnnex(this EventMsgSendRec item, string pars)
        {
            item.SetProperty(AnnexPropertyName, pars);
        }

        public static string GetAnnex(this EventMsgSendRec item)
        {
            return item.Property<string>(AnnexPropertyName);
        }
    }
}
